/*
 * readNextStep.cpp
 *
 *  Created on: Mar 30, 2014
 *      Author: marchi
 */
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <iterator>
#include <iomanip>
#include <cstring>
#include "AtomsXYZ.h"
#include "FstreamC.h"
#include "fxtc.h"

using namespace std;
// profile variables
static int ntime=0;

extern"C" {
void readNextStep(int & step,float * co, float * x, float * y, float * z, int & skip){
//void readNextStep(){
	Fstream & fin=*finx;
	int nr=atm->getNR();
    AtomsXYZ b=*(static_cast<AtomsXYZ *> (atm));

	if(fin.tellg() < len){
		if(!skip){
			fin >> *atm;
			cout << fixed << setw(5) << "----> Step No. " << setw(5) << right << fixed << ntime << " -- Time = " << atm->getTime() <<" ps \n";
			Metric Mt=atm->getMt();
			int cnt=0;
			for(size_t o=0;o<3;o++)
				for(size_t p=0;p<3;p++)
					co[cnt++]=Mt.getCO()[o][p];

			rvec * x0=atm->getX();
			for(size_t o=0;o<nr;o++){
				x[o]=x0[o][XX];
				y[o]=x0[o][YY];
				z[o]=x0[o][ZZ];
			}
		} else {
			fin+=*atm;
		}
	} else{
		step=-1;
		return;
	}
	step=ntime;
	ntime++;
}
}



